home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7658 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: news.nodak.edu!plains!ishaq
  2. From: ishaq@plains.nodak.edu (Jeffro)
  3. Newsgroups: comp.lang.c++
  4. Subject: Using cin like sscanf()?
  5. Date: 24 Feb 1996 21:02:37 GMT
  6. Organization: North Dakota Higher Education Computing Network (NDHECN)
  7. Message-ID: <4gnudd$dd4@daily-planet.nodak.edu>
  8. NNTP-Posting-Host: plains.nodak.edu
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=US-ASCII
  11. Content-Transfer-Encoding: 7bit
  12. X-Newsreader: TIN [version 1.2 PL2]
  13.  
  14. greetings!  I've always wondered if this is possible.  Well, I'm sure
  15. it's possible, but how is it done?  Say I input a string into string:
  16.  
  17. char string[] = "This is a character string.";
  18. char buffer[24];
  19.  
  20. How can I tell cin to read from string instead of stdin so I can do
  21. soemthing like this:
  22.  
  23. //cin.read_from(string)
  24. while (cin >> buffer) cout << buffer;    //Outputs string
  25. //cin.read_from(stdin)
  26.  
  27. This should be similar to:
  28.  
  29. while (sscanf(string, "%s", &buffer)) cout << buffer;
  30.  
  31. Any ideas?
  32. Thanks!
  33.     -jeff
  34. --
  35.  .,;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.
  36.  - Jeff Ishaq ishaq@plains.nodak.edu               Computer Science major -
  37.  - at North Dakota State University in Fargo, ND.  Drop me a line, eh?    -
  38.  .,;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.;';.,.
  39.  - better-than-average Phish songs:  Chalk Dust Torture, You Enjoy Myself,
  40.  - David Bowie, Mound, Split Open and Melt, My Friend (has got a knife),
  41.  - Fire Up The Ganga (live, of course), Contact
  42.